package com.stars.home.model;

import android.os.Parcel;
import android.os.Parcelable;

import com.stars.home.config.ConfigMMKV;
import com.trailer.base.inter.IModel;
import com.trailer.base.inter.IUser;
import com.trailer.base.utils.MMKVManager;

import org.jetbrains.annotations.Nullable;

public class User implements IUser, Parcelable, IModel {



    public String id;
    public String balance;
    public String technicianBalance;
    public String totalIncome;
    public String headImage;
    public String nickname;
    public String number;
    public String workTime;
    public int type;//0用户 1技师
    public int status;//0未认证 1认证中 2认证成功 -1认证失败
    public int isOnline;//0不在线 1在线
    public String createOrderNumber;
    public String successOrderNumber;
    public String meetOrderNumber;
    public String receivedNumber;
    public String sex;
    public String lifePhoto;
    public String address;
    public String successRate;
    public String onlineTime;
    public String wxNickname;
    public String introduce;


    protected User(Parcel in) {
        id = in.readString();
        balance = in.readString();
        technicianBalance = in.readString();
        totalIncome = in.readString();
        headImage = in.readString();
        nickname = in.readString();
        number = in.readString();
        workTime = in.readString();
        type = in.readInt();
        status = in.readInt();
        isOnline = in.readInt();
        createOrderNumber = in.readString();
        successOrderNumber = in.readString();
        meetOrderNumber = in.readString();
        receivedNumber = in.readString();
        sex = in.readString();
        lifePhoto = in.readString();
        address = in.readString();
        successRate = in.readString();
        onlineTime = in.readString();
        wxNickname = in.readString();
        introduce = in.readString();
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(id);
        dest.writeString(balance);
        dest.writeString(technicianBalance);
        dest.writeString(totalIncome);
        dest.writeString(headImage);
        dest.writeString(nickname);
        dest.writeString(number);
        dest.writeString(workTime);
        dest.writeInt(type);
        dest.writeInt(status);
        dest.writeInt(isOnline);
        dest.writeString(createOrderNumber);
        dest.writeString(successOrderNumber);
        dest.writeString(meetOrderNumber);
        dest.writeString(receivedNumber);
        dest.writeString(sex);
        dest.writeString(lifePhoto);
        dest.writeString(address);
        dest.writeString(successRate);
        dest.writeString(onlineTime);
        dest.writeString(wxNickname);
        dest.writeString(introduce);
    }

    public static final Creator<User> CREATOR = new Creator<User>() {
        @Override
        public User createFromParcel(Parcel in) {
            return new User(in);
        }

        @Override
        public User[] newArray(int size) {
            return new User[size];
        }
    };

    @Nullable
    public static User get() {
        return MMKVManager.instance().decodeParcelable(ConfigMMKV.USER, User.class);
    }

    @Override
    public boolean save() {
        return MMKVManager.instance().encode(ConfigMMKV.USER, this);
    }


    @androidx.annotation.Nullable
    @Override
    public String avatar() {
        return headImage;
    }

    @Override
    public int describeContents() {
        return 0;
    }


}
